﻿namespace System.Modules.Contracts.Attributes
{
    /// <summary>
    /// Binding Field | Used to Bind DTO property to a data source Field
    /// </summary>
    [AttributeUsage(AttributeTargets.Property)]
    public class BindingField : Attribute
    {
        #region Public Properties
        /// <summary>
        /// Field Name
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// Function to retrieve Field Value.
        /// </summary>
        public Func<object, object> Function { get; set; }
        #endregion

        #region Constructor
        /// <summary>
        /// Default Constructor
        /// </summary>
        public BindingField() {}

        /// <summary>
        /// Set Field Name
        /// </summary>
        /// <param name="fieldName"></param>
        public BindingField(string fieldName)
        {
            Name = fieldName;
        }

        /// <summary>
        /// Mapping SP Field | Field Name | Function to return Field Value
        /// </summary>
        /// <param name="fieldName"> </param>
        /// <param name="function"></param>
        public BindingField(string fieldName, Func<object, object> function)
        {
            Name = fieldName;
            Function = function;
        }
        #endregion
    }
}
